package com.bdqn.t320.ch01.controller;

import com.bdqn.t320.ch01.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class HelloController {

    @Resource
    UserService userService;

    @Value("${com.ktjiaoyu.name}")
    private String name;
    @Value("${com.ktjiaoyu.email}")
    private String email;

    @RequestMapping("/hello")
    public String hello(String uname) {
        System.out.println("uname:" + uname);
        userService.addUser(uname);
        return "uname:" + uname;
    }

    @RequestMapping("/show")
    public String show() {
        String msg = name + "," + email;
        return msg;
    }
}
